package com.example.practical_training_projects.service;

import com.example.practical_training_projects.entity.articles;
import com.example.practical_training_projects.mapper.articlesMapper;
import com.example.practical_training_projects.vo.voarticlesandclass;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class articlesServicelmpl implements articlesService {
  @Autowired
  private articlesMapper mapper;
   @Override
   public List<articles> getThearticles(Integer a_uid) {
       List<articles> allarticles = mapper.getThearticles(a_uid);
        return allarticles;
    }


    @Override
    public PageInfo<voarticlesandclass> findclasspage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<voarticlesandclass> lists=mapper.findAllarticlesandclass();
        PageInfo<voarticlesandclass> pageInfo=new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public articles findarticlesbyid(Integer a_uid) {
        return mapper.findarticlesbyid(a_uid);
    }

    @Override
    public Integer deletearticlesbyid(Integer a_uid) {
        return mapper.deletearticlesbyid(a_uid);
    }

    @Override
    public Integer insertarticles(articles art) {
        return mapper.insertarticles(art);
    }

    @Override
    public Integer updatearticles(articles art) {
        return mapper.updatearticles(art);
    }

    @Override
    public List<voarticlesandclass> findAllarticlesandclass() {
        return mapper.findAllarticlesandclass();
    }


    @Override
    public PageInfo<voarticlesandclass> findarticlesBytitle(String a_title,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<voarticlesandclass> lists=mapper.findarticlesBytitle(a_title);
        PageInfo<voarticlesandclass> pageInfo=new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<voarticlesandclass> findarticlesBytitleAndclassuid(Integer as_uid,String a_title,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<voarticlesandclass> lists=mapper.findarticlesBytitleAndclassuid(as_uid,a_title);
        PageInfo<voarticlesandclass> pageInfo=new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public List<articles> selectauid(String a_title) {
        return mapper.selectauid(a_title);
    }

}
